package vsm.vsm_server.mapper;


import org.apache.ibatis.annotations.*;

import java.math.BigInteger;
import java.util.List;

@Mapper
public interface RelationMapper {
    /*
    查询是否关注某用户
     */
    @Select("select relation from follow where userId=#{userid} and followId=#{followid}")
    Integer isFollow(BigInteger userid, BigInteger followid);

    /*
    关注用户
     */
    @Insert("insert into follow(userid,followid,relation) values(#{userid},#{followid},#{relation})")
    Boolean follow(BigInteger userid, BigInteger followid, Integer relation);
    /*
   取消用户
    */
    @Delete("delete from follow where userId=#{userid} and followId=#{followid}")
    Boolean delete(BigInteger userid, BigInteger followid);
    /*
    修改用户关系
     */
    @Update("update follow set relation = #{relation} where userId=#{userid} and followId=#{followid}")
    Boolean update(BigInteger userid, BigInteger followid,Integer relation);

    /*
    获得关注列表
     */
    @Select("select followid from follow where userid = #{userid}")
    List<BigInteger> getSubs(BigInteger userid);
    /*
    获得粉丝列表
     */
    @Select("select userid from follow where followid = #{followid}")
    List<BigInteger> getFans(BigInteger followid);
}
